﻿using System;
using System.Collections.Generic;
using System.Linq;

using System.Text;
using System.Threading.Tasks;
using Sharp.DataTransferObject.Workflow;
using Sharp.Infrastructure;
using Sharp.Infrastructure.Interfaces;
using Sharp.Infrastructure.Search;

namespace Sharp.ServiceContracts
{
    /// <summary>
    /// 工作流服务
    /// </summary>
    [ContractTag(Tag = ContractTagEnum.Authorize)]
    public interface IWorkflowService : IApplicationServiceContract
    {
        /// <summary>
        /// 保存流程
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        
        Result SaveProcess(ProcessDTO model);
        /// <summary>
        /// 创建流程定义记录
        /// </summary>
        /// <param name="entity">流程定义实体</param>
        /// <returns>新ID</returns>
        
        
        int CreateProcess(ProcessDTO entity);
        ///// <summary>
        ///// 更新流程定义记录
        ///// </summary>
        ///// <param name="entity">流程</param>
        //
        //
        //void UpdateProcess(ProcessDTO entity);

        /// <summary>
        /// 删除流程定义记录
        /// </summary>
        /// <param name="processGUID">流程GUID</param>
        /// <param name="version">版本</param>
        
        
        void DeleteProcess(string processGUID, string version);

        /// <summary>
        /// 删除流程定义记录
        /// </summary>
        /// <param name="ids"></param>
        
        
        Result DeleteProcessById(int[] ids);

        /// <summary>
        /// 流程定义数据读取
        /// </summary>
        /// <param name="processGUID">流程定义GUID</param>
        /// <param name="version">版本号</param>
        /// <returns>流程</returns>
        
        
        ProcessDTO GetProcessByVersion(string processGUID, string version = null);

        /// <summary>
        /// 获取流程定义数据（只包括基本属性）
        /// </summary>
        /// <returns></returns>
        
        
        IList<ProcessDTO> GetProcessListSimple();

        /// <summary>
        /// 获取当前版本的流程定义记录
        /// </summary>
        /// <param name="processGUID">流程GUID</param>
        /// <returns>流程</returns>
        
        
        ProcessDTO GetProcess(string processGUID);

        /// <summary>
        /// 保存流程定义的xml文件
        /// </summary>
        /// <param name="entity">流程文件实体</param>
        
        
        void SaveProcessFile(ProcessFileDTO entity);

        /// <summary>
        /// 获取分页数据
        /// </summary>
        /// <param name="pf"></param>
        /// <returns></returns> 
        
        
        PagedResult<ProcessDTO> GetProcessPaged(PagingFeature pf);
        /// <summary>
        ///  获取正在运行中的活动实例
        ///  </summary>
        ///  <param name="appInstanceID">应用实例ID</param>
        ///  <param name="processGUID">流程GUID</param>
        /// <returns>活动实例列表</returns>
        
        
        IList<ActivityInstanceDTO> GetRunningActivityInstance(string appInstanceID, string processGUID);

        /// <summary>
        /// 流程定义的XML文件获取
        /// </summary>
        /// <param name="processGUID">流程GUID</param>
        /// <param name="version">版本</param>
        /// <returns>流程文件</returns>
        
        
        ProcessFileDTO GetProcessFile(string processGUID, string version);

        /// <summary>
        /// 获取流程定义文件
        /// </summary>
        /// <param name="id">流程ID</param>
        /// <returns></returns>
        
        
        ProcessFileDTO GetProcessFileByID(int id);
        /// <summary>
        /// 获取流程定义文件
        /// </summary>
        /// <param name="id">流程ID</param>
        /// <returns></returns>
        
        
        ProcessDTO GetProcessInfo(int id);

        /// <summary>
        /// 获取待处理流程实例分页数据
        /// </summary>
        /// <param name="pf"></param>
        /// <returns></returns> 
        
        
        PagedResult<TaskDTO> GetReadyTasksPaged(PagingFeature pf);
        /// <summary>
        /// 获取已完成流程实例分页数据
        /// </summary>
        /// <param name="pf"></param>
        /// <returns></returns> 
        
        
        PagedResult<TaskDTO> GetCompletedTasksPaged(PagingFeature pf);
    }
}
